home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / newsgroups / misc.19960715-19961006 / 000041_news@columbia.edu _Sun Jul 21 10:28:47 1996.msg < prev    next >
Internet Message Format  |  1996-11-03  |  4KB

  1. Return-Path: news@columbia.edu
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30]) by watsun.cc.columbia.edu (8.7.5/8.7.3) with ESMTP id KAA16209 for <kermit.misc@watsun.cc.columbia.edu>; Sun, 21 Jul 1996 10:28:47 -0400 (EDT)
  3. Received: (from news@localhost) by newsmaster.cc.columbia.edu (8.7.5/8.7.3) id KAA25776 for kermit.misc@watsun; Sun, 21 Jul 1996 10:28:46 -0400 (EDT)
  4. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  5. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  6. Newsgroups: comp.protocols.kermit.misc
  7. Subject: Re: MSK to K95 script string question (with \)
  8. Date: 21 Jul 1996 14:28:25 GMT
  9. Organization: Columbia University
  10. Lines: 74
  11. Message-ID: <4steq9$cs5@apakabar.cc.columbia.edu>
  12. References: <1996Jul19.144659.143932@forest>
  13. NNTP-Posting-Host: watsun.cc.columbia.edu
  14.  
  15. In article <1996Jul19.144659.143932@forest>,
  16. Paul Coen <pcoen@forest.drew.edu> wrote:
  17. : I'm trying to convert some old MS-Kermit scripts over to K95.  We've got
  18. : a system where you hit a key, it tells the remote system to send a macro
  19. : file, Kermit runs the macro, and part of that macro prompts you for
  20. : a destination filename, and then goes and gets the mail message (We have it
  21. : tied into DEC's all-in-1 software) and puts it where you told it to.
  22. : So, you'd be asked to enter, say C:\DOCS\TEST.TXT.
  23. : Works with MS-Kermit (I didn't write the original script, by the way).
  24. : It will work with K95 -- if you use / or \\ as the directory indicators.
  25. : (And I can understand why).  The problem is that my boss doesn't want us
  26. : to have to retrain everyone for a special case.  (We have a similar 
  27. : problem with the "upload a message" feature we did as well).
  28. : The macro is doing:
  29. : ask \%N {Filename for your computer or END:}
  30. : it then checks to see if it equals end or if the file already exists.
  31. : Is there any way I could re-format the string to add the second slash
  32. : at each occurance in the user string?  My instinct is to say "no," since
  33. : I suspect that the single \ is treated as a special character and I can't
  34. : look for it.  
  35. :
  36. Diagnosis correct.  The fact that the Kermit script language's
  37. distinguished character, backslash, is the same as the directory separator
  38. in DOS, Windows, OS/2, etc, can be a headache.
  39.  
  40. The ASK command doesn't do anything to the characters that the user types,
  41. so if the user typed "C:\DOCS\TEST.TXT", that's what the variable contains.
  42. The problem occurs when you *use* the variable.  Whenever you refer to a
  43. variable, it is evaluated recursively, which USUALLY produces the desired
  44. effect.  For example:
  45.  
  46.   define \%a some
  47.   define \%b thing
  48.   define \%c \%a\%b
  49.   echo \%c
  50.  
  51. displays "something" rather than "\%a\%b".  If the variable is a DOS
  52. filename containing backslashes, the same thing happens, with the results
  53. depending on the character that follows each backslash.
  54.  
  55. The trick is to tell your script to replace the variable by its literal
  56. definition, rather than evaluating it recursively.  That is, the evaluation
  57. should go only one level deep.
  58.  
  59. The method for doing this depends on which type of variable it is.  If it's
  60. a "backslash" variable, like \%N, \%F[3], etc, then use:
  61.  
  62.  \fcontents(variable-name)
  63.  
  64. For example:
  65.  
  66.   def \%f
  67.   while not def \%f { ask \%f { Filename: } }
  68.   echo The filename is \fcontents(\%f).
  69.   send \fcontents(\%f)
  70.  
  71. If it is a "long filename", do it this way:
  72.  
  73.   def filename
  74.   while not def filename { ask filename { Filename: } }
  75.   echo The filename is \m(filename).
  76.   send \m(filename)
  77.  
  78. You can find lots of examples of how to deal with DOS filenames in the
  79. HOSTMODE.KSC script in the Kermit 95 SCRIPTS directory.
  80.  
  81. - Frank